package com.gzyz.cheetah.config;

import com.gzyz.cheetah.interceptor.AdminJwtInterceptor;
import com.gzyz.cheetah.interceptor.DownloadInterceptor;
import com.gzyz.cheetah.interceptor.UserJwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @author xclhove
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userJwtInterceptor());
        registry.addInterceptor(adminJwtInterceptor());
        registry.addInterceptor(getIdInInterceptor());
    }
    
    @Bean
    public UserJwtInterceptor userJwtInterceptor() {
        return new UserJwtInterceptor();
    }
    
    @Bean
    public AdminJwtInterceptor adminJwtInterceptor() {
        return new AdminJwtInterceptor();
    }
    
    @Bean
    public DownloadInterceptor getIdInInterceptor() {
        return new DownloadInterceptor();
    }
}
